package com.iwayin.web.action.vote;

import com.iwayin.core.bo.vote.VoteBO;
import com.iwayin.core.dataobject.AnswerVoteDO;
import com.iwayin.core.utils.exception.BOException;
import com.iwayin.web.action.BaseAction;
import com.iwayin.web.common.AjaxResult;

public class VoteAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2207537497659587550L;

	private AnswerVoteDO vote;
	private AjaxResult ajaxResult;
	private VoteBO voteBO;

	/**
	 * 投票
	 * 
	 * @return
	 */
	public String addVote() {
		try {
			vote.setUserId(this.getLoginUser().getId());
			voteBO.addVote(vote);

			ajaxResult = AjaxResult.succResult();
		} catch (BOException e) {
			ajaxResult = AjaxResult.errorResult(e.getMessage());
		} catch (Exception e) {
			ajaxResult = AjaxResult.errorResult("投票失败，请重试");
		}
		return SUCCESS;
	}

	public AnswerVoteDO getVote() {
		return vote;
	}

	public void setVote(AnswerVoteDO vote) {
		this.vote = vote;
	}

	public AjaxResult getAjaxResult() {
		return ajaxResult;
	}

	public void setVoteBO(VoteBO voteBO) {
		this.voteBO = voteBO;
	}

}
